| Randomize |
|
 |
| Description
|
|
Seeds the ColdFusion random number generator with an integer number. Seeding the generator helps ensure that the Rand function generates highly random numbers.
|
| |
| Returns
|
|
A non-random decimal number, in the range 0 - 1.
|
| |
| Category
|
|
Mathematical functions
|
| |
| Function syntax |
Randomize(number)
|
| |
| See also
|
|
Rand, RandRange
|
| |
| Parameters
|
| |
| Parameter |
Description |
| number |
A number |
|
| |
| Usage
|
|
Call this function before calling Rand. Although this function returns a decimal number, it is not a random number.
|
| |
Example<h3>Randomize Example</h3>
<p>Call Randomize to seed the random number generator. This helps
to ensure the randomness of numbers generated by Rand.
<cfif IsDefined("FORM.myRandomInt")>
<cfif IsNumeric(FORM.myRandomInt)>
<cfoutput><p><b>Seed value is #FORM.myRandomInt#</b>
</cfoutput><br>
<cfset r = Randomize(FORM.myRandomInt)>
<cfloop index = "i" from = "1" to = "10" step = "1">
<cfoutput>Next random number is #Rand()#</cfoutput><br>
</cfloop><br>
<cfelse>
<p>Please enter a number.
</cfif>
</cfif>
<form action = "randomize.cfm">
<p>Enter a number to seed the randomizer:
<input type = "Text" name = "MyRandomInt">
<p><input type = "Submit" name = "">
</form>
|